package thread;

public class ThreadDemo19 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread t1 = new Thread(()->{
            synchronized (locker){//计数器+1//这两个加锁,其实针对的是同一个线程
            synchronized (locker){//计数器+1
                System.out.println("hello");
            }//计数器-1
          }//计数器-1,此时计数器为0,锁释放
        });
        t1.start();
    }
}
